package com.hyy.controller;

import com.hyy.bean.MaskOrder;
import com.hyy.bean.MaskUser;
import com.hyy.bean.OrderProduct;
import com.hyy.service.OrderService;
import com.hyy.service.serviceImpl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet(name = "ToUsermsgServlet",urlPatterns = "/toUsermsg")
public class ToUsermsgServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req,resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		Long uid = ((MaskUser) req.getSession().getAttribute("user")).getUserid();
		OrderService orderService = new OrderServiceImpl();
		/*List<MaskOrder> orders = orderService.showOrderByUid(uid);

		Map<MaskOrder,List<OrderProduct>> orderMap = new HashMap<>();
		for (MaskOrder order : orders) {
			orderMap.put(order,orderService.showProductByOid(order.getOrderId()));
		}
		req.setAttribute("orderMap",orderMap);*/

		req.getRequestDispatcher("/jsp/usermsg.jsp").forward(req,resp);
	}
}
